package com.woniuxy.springparking.controller;

import com.woniuxy.springparking.asepct.SysLog;
import com.woniuxy.springparking.common.RestDto;
import com.woniuxy.springparking.common.RestResult;
import com.woniuxy.springparking.service.McarParkingService;
import com.woniuxy.springparking.service.TPerStallService;
import com.woniuxy.springparking.vo.McarParkingVo;
import com.woniuxy.springparking.vo.TPerStallVo;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class McarParkingController {

    @Autowired
    private McarParkingService mcarParkingService;

    @GetMapping("/toMParkingByPage")
    @ApiOperation(value = "分页查询所有商户车位信息",httpMethod = "GET",
            protocols = "HTTP",produces = "application/json",
            response = RestResult.class,notes = "分页查询所有商户车位信息")
    public RestResult toMParkingByPage(McarParkingVo mpVo){
        return this.mcarParkingService.seletMPByPage(mpVo);
    }

    @DeleteMapping("/delMC.do")
    @ApiOperation(value = "按id删除商户车位信息",httpMethod = "DELETE",
            protocols = "HTTP",produces = "application/json",
            response = RestDto.class,notes = "按id删除商户车位信息")
    @SysLog(value1 = "删除",value2 = "删除车位")
    public RestDto delMC(Integer id){
        RestDto dto = new RestDto();
        try {
            this.mcarParkingService.delMC(id);
            dto.setCode(200);
            dto.setMsg("删除成功");
        } catch (Exception e) {
            e.printStackTrace();
            dto.setCode(-1);
            dto.setMsg("删除成功");
        }
        return dto;
    }
}
